package com.itheima.web.controller;

import com.itheima.pojo.User;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Map;

/**
 * @author huyoufu <https://github.com/huyoufu>
 * @TIME 2020-08-11 09:37
 * @description
 */


@Controller
@RequestMapping("/user06")
public class demo6_参数绑定2 {

    //想要什么数据 直接写在参数位置,带上参数我就能获取到
    @RequestMapping("/login.do")
    public String login(Model model,String username,String password) throws ServletException, IOException {
        System.out.println("用户登录...");

        System.out.println("获取用户名:"+username);
        System.out.println("获取用密码:"+password);

        //调用service  查询用户.......

        model.addAttribute("info","模拟的登录数据");

        return "user/success";
    }

    @RequestMapping("/register.do")
    public String register(Model model,User user) throws ServletException, IOException {
        System.out.println("用户注册...");

        System.out.println("封装完的结果:"+user);

        //调用service 保存用户....

        model.addAttribute("info","模拟的注册数据");

        return "user/success";

    }

    @RequestMapping("/logout.do")
    public String logout(Model model) throws ServletException, IOException {
        System.out.println("退出登录...");

        model.addAttribute("info","模拟的推出登录数据");

        return "user/success";

    }
}
